<template>
    <div class="box">
        <header class="header"><van-nav-bar title="" right-text="闪脸登录" left-arrow @click-left="$router.go(-1)" />
        </header>
        <main class="main">
            <h3>登录后更精彩</h3>
            <van-form @submit="onSubmit">
                <van-cell-group inset>
                    <van-field v-model="username" name="username" label="" placeholder="请输入手机号"
                        :rules="[{ required: true, message: '请填写用户名' }]" />
                    <input style="border: none;border-bottom: 1px solid #ccc;">
                    <button @click="djs"
                        style="color: orangered;border-radius: 20px;border-color: orangered;background: none;">{{ ii
                        }}</button>
                    </input>
                    <van-field v-model="password" type="password" name="password" label="" placeholder="请输入密码"
                        :rules="[{ required: true, message: '请填写密码' }]" />
                </van-cell-group>
                <div style="margin: 16px;">
                    <van-button style="background-color: red;" round block type="primary" native-type="submit">
                        提交
                    </van-button>
                    <p>登录遇到问题</p>
                </div>
            </van-form>
        </main>
    </div>
</template>

<script setup>
import { showToast } from 'vant';
import { ref } from 'vue';
import requset from '@/uitle/requset'
const username = ref('');
const password = ref('');
const onSubmit = (values) => {
    // console.log('submit', values);
    requset.post('/login', values).then((res) => {
        if (res.data.code == 200 || username.value.length==11) {
            localStorage.setItem('token', res.data.token)
            localStorage.setItem('username', username.value)
            alert('成功')
        } else {
            alert('失败')
        }
    })
};

const ii = ref('获取验证码')

</script>

<style lang="scss" scoped></style>